package com.neusoft.newelm.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.neusoft.newelm.bean.Admin;
import com.neusoft.newelm.common.ElmException;

/**
 * 
 * @author chens
 *
 */
public interface AdminMapper extends BaseMapper<Admin> {

	/**
	 * 根据用户的账号和密码执行登录操作
	 * 
	 * 
	 * @param admin
	 * @return
	 * 
	 */
	@Select("select adminId,adminName,password,salt,headImage from admin where adminName=#{adminName}")
	public Admin login(Admin admin);

	/**
	 * 新增
	 * 
	 * @param object
	 * @return
	 */
	boolean add(Admin object);

	/**
	 * 修改
	 * 
	 * @param object
	 * @return
	 */
	@Update("update admin set password=#{password},salt=#{salt},headImage=#{headImage} where adminId=#{adminId}")
	boolean edit(Admin object);

	/**
	 * 根据主键删除
	 * 
	 * @param id
	 * @return
	 */
	@Delete("delete from admin where adminId=#{adminId}")
	boolean deleteById(Integer id);

	/**
	 * 根据主键查询
	 * 
	 * @param id
	 * @return
	 */
	@Select("select adminId,adminName,password,salt,headImage from admin where adminId=#{adminId}")
	Admin findById(Integer id);

}
